// DropletComponents.h

#ifdef _WIN32
#pragma once
#endif

#ifndef _DROPLET_COMPS_
#define _DROPLET_COMPS_

#ifdef _WIN32
	#include "inttypes.h"
	#include "DropletGlobals.h"
	#include "Message.h"
	
	#include <map>
	#include <deque>
	#include <cmath>
	#include <time.h>

#define APPX_PI 3.1416

#else 
	#include <inttypes.h>
#endif

using namespace Droplets;

// Add all droplet component functions and global data here. 
// These functions should match the robot avr library we are writing for the swarm.
namespace Droplets 
{
	enum VizColors 
	{
		RED = 1,
		GREEEN = 2,
		BLUE = 3
	};

	enum Legs
	{
		FRONT = 1,
		REAR_LEFT = 2,
		REAR_RIGHT = 3
	};

	typedef enum Direction
	{
		NORTH,
		SOUTH,
		EAST,
		WEST
	} Direction_e;

	// ROBOT SETUP
	void InitDroplet();
	void SetupLEDs();
	void SetupIRSensors();
	void SetupRGBSensor();
	void SetupComm(uint16_t robotID);	// Setup communication
	void SetupMotors();
	
	// ROBOT SUBSYSTEM - Timer
	void SetupTimer(int16_t ms);
	void StartTimer();
	void StopTimer();

	// ROBOT SUBSYSTEM - RGB LED and Sensor
	void GetRGBLED (VizColors color, uint8_t *bt); 
	void SetRGBLED (VizColors color, uint8_t bt);
	void SenseRGB(VizColors color, uint16_t *bt);


	// ROBOT SUBSYSTEM - Motion
	// May want getters...
	void Rotate(int16_t angle, uint8_t speed);	// angle in degrees
	void Move(uint16_t dir, uint8_t speed, uint8_t dur);
	bool IsMoving();
	bool IsRotating();


	// ROBOT SUBSYSTEM - Power
	void CapacitorPower(uint16_t *power);
	void SystemPower(Legs leg, int8_t *power);	// -1, 0, +1 - on power, ground, off power
//	TODO : Define	void (*SystemPowerHandler)(void);

	// ROBOT SUBSYSTEM - IR Sensors / Comm
	void SendPacket(uint8_t *data,
		uint8_t length,
		Direction_e dir, 
		uint8_t priority,
		uint8_t distance);	// distance in cm

//	TODO : Define	void (*ReceivePacketHandler)(Message *msg);		
	void SenseIR(Direction_e dir, uint16_t *bt);

	// ROBOT HELPER FUNCTIONS
	uint16_t Random(uint16_t max);
}

#endif